package com.ruint.master.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.ruint.core.app.BaseActivity;
import com.ruint.lib.swipeback.SwipeBackLayout;
import com.ruint.master.R;
import com.ruint.master.app.fragment.DiaryListFragment;
import com.ruint.master.view.TabTopbar;

public class MainActivity extends BaseActivity {
  TabTopbar topbar;

  @Override
  protected int getLayoutResID() {
    return R.layout.activity_main;
  }

  @Override
  protected void pre4Create(Bundle savedInstanceState) {
    setSwipeBack(SWIPE_BACK_ENABLE);
    setSwipeBackOrientation(SwipeBackLayout.EDGE_LEFT);
  }

  @Override
  protected void findViews() {
    topbar = (TabTopbar) findViewById(R.id.topbar);
  }

  @Override
  protected void handleRelevancy() {
    topbar.setRightButton("写日记").getRightButton().setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        startActivity(new Intent(thisInstance, ImgUploadActivity.class));
      }
    });
  }

  @Override
  protected void onLoadingData() {
    getSupportFragmentManager().beginTransaction().replace(R.id.d_list_frame, new DiaryListFragment()).commit();
  }

}
